package com.lineage.data.item_etcitem;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class AddExpPotion extends ItemExecutor {
  private static final Log _log = LogFactory.getLog(AddExpPotion.class);
  
  private int _add_exp = 1;
  
  public static ItemExecutor get() {
    return new AddExpPotion();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    try {
      if (item == null)
        return; 
      if (pc == null)
        return; 
      pc.getInventory().removeItem(item, 1L);
      long exp = this._add_exp;
      if (exp > 0L)
        pc.addExp(exp); 
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
  
  public void set_set(String[] set) {
    try {
      this._add_exp = Integer.parseInt(set[1]);
      if (this._add_exp <= 0) {
        _log.error("UserHpr 设置错误:最小恢复质小于等于0! 使用预设1");
        this._add_exp = 1;
      } 
    } catch (Exception exception) {}
  }
}
